<template>
    <div class="dashboard-list-container">
        <global-search @submitSearch="submitSearch" class="global-tool-search">
            <template slot="other-form">
                <el-form-item label="住院日大于" class="form-days">
                    <el-input v-model="form.hosDays" class="days" placeholder=""></el-input>
                    <span class="unit">天</span>
                </el-form-item>
                <el-form-item label="检索">
                    <el-input v-model="form.keyword" clearable placeholder="请输入病案号搜索"></el-input>
                </el-form-item>
            </template>
            <template slot="tool-box">
                <el-button type="text" v-auth="{code: 200001002001}" @click="toExport">
                    <svg-icon icon-class="export"/>
                    导出
                </el-button>
            </template>
        </global-search>
        <div class="tables-box">
            <el-tabs v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="全部" name="all">
                    <el-table
                        border
                        v-if="activeName === 'all'"
                        :data="tableData"
                        row-key="medicalRecordID"
                        :max-height="tableHeight"
                        tooltip-effect="light"
                        :empty-text="emptyText"
                        @sort-change="sortChange"
                        @selection-change="handleSelectionChange">
                        <el-table-column
                            show-overflow-tooltip
                            type="selection"
                            align="center"
                            width="30">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="date"
                            align="center"
                            type="index"
                            label="序号"
                            width="40">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="medicalRecordSign"
                            align="center"
                            label="病案号"
                            min-width="90">
                            <template slot-scope="scope">
                                <el-button type="text" :disabled="!viewInfoMonth(scope.row.dischargeDate)"
                                    @click="toInfo(scope.$index)">{{scope.row.medicalRecordSign}}
                                </el-button>
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="patientName"
                            align="center"
                            label="患者姓名"
                            min-width="65">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="dischargeDate"
                            align="center"
                            sortable="custom"
                            label="出院时间"
                            min-width="85">
                            <template slot-scope="scope">
                                {{scope.row.dischargeDate.substring(0, 10)}}
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="hospitalTime"
                            align="center"
                            sortable="custom"
                            label="住院次数"
                            min-width="80">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="totalFee"
                            align="center"
                            sortable="custom"
                            label="住院总费用"
                            min-width="95">
                            <template slot-scope="scope">
                                {{scope.row.totalFee | getMoneyNum}}
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            align="center"
                            label="组均住院费用">
                            <el-table-column
                                show-overflow-tooltip
                                prop="drgAvgFee"
                                align="center"
                                label="院内"
                                min-width="80">
                                <template slot="header" slot-scope="scope">
                                    <el-tooltip class="item" effect="light" content="计算院内该组数据3年内的平均值" placement="top">
                                        <span>院内</span>
                                    </el-tooltip>
                                </template>
                                <template slot-scope="scope">
                                    <span v-if="scope.row.state === '已入组' || scope.row.drgAvgFee">{{scope.row.drgAvgFee | getMoneyNum}}</span>
                                    <span v-else>/</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="drgStandardFee"
                                align="center"
                                sortable="custom"
                                label="区域"
                                min-width="80">
                                <template slot-scope="scope">
                                    <span v-if="scope.row.state === '已入组' || scope.row.drgStandardFee">{{scope.row.drgStandardFee | getMoneyNum}}</span>
                                    <span v-else>/</span>
                                </template>
                            </el-table-column>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="drgIncome"
                            align="center"
                            sortable="custom"
                            label="DRG盈亏"
                            min-width="85">
                            <template slot-scope="scope">
                                <span v-if="scope.row.state === '已入组' || scope.row.drgIncome">{{scope.row.drgIncome | getMoneyNum}}</span>
                                <span v-else>/</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="hospitalDays"
                            align="center"
                            sortable="custom"
                            label="住院日"
                            min-width="65">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            align="center"
                            label="组均住院日">
                            <el-table-column
                                show-overflow-tooltip
                                prop="drgAvgDays"
                                align="center"
                                label="院内"
                                min-width="50">
                                <template slot="header" slot-scope="scope">
                                    <el-tooltip class="item" effect="light" content="计算院内该组数据3年内的平均值" placement="top">
                                        <span>院内</span>
                                    </el-tooltip>
                                </template>
                                <template slot-scope="scope">
                                    <span v-if="scope.row.state === '已入组'">{{scope.row.drgAvgDays}}</span>
                                    <span v-else>{{scope.row.drgAvgDays ? scope.row.drgAvgDays : '/'}}</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="drgStandardDays"
                                align="center"
                                sortable="custom"
                                label="区域"
                                min-width="55">
                                <template slot-scope="scope">
                                    <span v-if="scope.row.state === '已入组'">{{scope.row.drgStandardDays}}</span>
                                    <span v-else>{{scope.row.drgStandardDays ? scope.row.drgStandardDays : '/'}}</span>
                                </template>
                            </el-table-column>
                        </el-table-column>
                        <el-table-column
                            prop="drgCode"
                            align="center"
                            label="分组编码"
                            min-width="70">
                            <template slot-scope="scope">
                                <el-tooltip v-if="scope.row.multiGroup.length" class="item" effect="light" placement="top">
                                    <div slot="content">
                                        <div v-for="(item, index) in scope.row.multiGroup">{{(index + 1) + '、' + item.key}}</div>
                                    </div>
                                    <span class="exceed-text">{{scope.row.drgCode}}</span>
                                </el-tooltip>
                                <el-tooltip v-else class="item" effect="light" placement="top">
                                    <div slot="content">
                                        <div>{{scope.row.drgCode}}</div>
                                    </div>
                                    <span class="exceed-text">{{scope.row.drgCode}}</span>
                                </el-tooltip>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="drgName"
                            align="left"
                            header-align="center"
                            label="分组名称"
                            min-width="100">
                            <template slot-scope="scope">
                                <el-tooltip v-if="scope.row.multiGroup.length" class="item" effect="light" placement="top">
                                    <div slot="content">
                                        <div v-for="(item, index) in scope.row.multiGroup">{{(index + 1) + '、' + item.value}}</div>
                                    </div>
                                    <span class="exceed-text">{{scope.row.drgName}}</span>
                                </el-tooltip>
                                <el-tooltip v-else class="item" effect="light" placement="top">
                                    <div slot="content">
                                        <div>{{scope.row.drgName}}</div>
                                    </div>
                                    <span class="exceed-text">{{scope.row.drgName}}</span>
                                </el-tooltip>
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="type"
                            align="center"
                            sortable="custom"
                            label="类型"
                            min-width="65">
                            <template slot-scope="scope">
                                <span v-if="scope.row.state === '已入组'" :class="{'status-blue': scope.row.type === 1, 'status-red': scope.row.type === 2}">{{scope.row.type | getType}}</span>
                                <span v-else>/</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="riskLevel"
                            align="center"
                            sortable="custom"
                            label="风险等级"
                            min-width="80">
                            <template slot-scope="scope">
                                <span v-if="scope.row.state === '已入组'">{{scope.row.riskLevel | getRiskLevel}}</span>
                                <span v-else>/</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="state"
                            align="center"
                            sortable="custom"
                            label="状态"
                            min-width="60"
                            fixed="right">
                            <template slot-scope="scope">
                                <span :class="scope.row.state === '已入组' ? 'status-green' : 'status-red'">{{scope.row.state}}</span>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="已入组" name="included">
                    <el-table
                        border
                        v-if="activeName === 'included'"
                        :data="tableData"
                        row-key="id"
                        :max-height="tableHeight"
                        tooltip-effect="light"
                        style="width: 100%"
                        :empty-text="emptyText"
                        @sort-change="sortChange"
                        @selection-change="handleSelectionChange">
                        <el-table-column
                            show-overflow-tooltip
                            type="selection"
                            align="center"
                            width="30">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="date"
                            align="center"
                            type="index"
                            label="序号"
                            width="40">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="medicalRecordSign"
                            align="center"
                            label="病案号"
                            min-width="90">
                            <template slot-scope="scope">
                                <el-button type="text" :disabled="!viewInfoMonth(scope.row.dischargeDate)"
                                           @click="toInfo(scope.$index)">{{scope.row.medicalRecordSign}}
                                </el-button>
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="patientName"
                            align="left"
                            label="患者姓名"
                            min-width="65">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="dischargeDate"
                            align="center"
                            sortable="custom"
                            label="出院时间"
                            min-width="85">
                            <template slot-scope="scope">
                                {{scope.row.dischargeDate.substring(0, 10)}}
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="hospitalTime"
                            align="center"
                            sortable="custom"
                            label="住院次数"
                            min-width="80">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="totalFee"
                            align="center"
                            sortable="custom"
                            label="住院总费用"
                            min-width="95">
                            <template slot-scope="scope">
                                {{scope.row.totalFee | getMoneyNum}}
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            align="center"
                            label="组均住院费用">
                            <el-table-column
                                show-overflow-tooltip
                                prop="drgAvgFee"
                                align="center"
                                label="院内"
                                min-width="80">
                                <template slot="header" slot-scope="scope">
                                    <el-tooltip class="item" effect="light" content="计算院内该组数据3年内的平均值" placement="top">
                                        <span>院内</span>
                                    </el-tooltip>
                                </template>
                                <template slot-scope="scope">
                                    <span v-if="scope.row.state === '已入组' || scope.row.drgAvgFee">{{scope.row.drgAvgFee | getMoneyNum}}</span>
                                    <span v-else>/</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="drgStandardFee"
                                align="center"
                                sortable="custom"
                                label="区域"
                                min-width="80">
                                <template slot-scope="scope">
                                    <span v-if="scope.row.state === '已入组' || scope.row.drgStandardFee">{{scope.row.drgStandardFee | getMoneyNum}}</span>
                                    <span v-else>/</span>
                                </template>
                            </el-table-column>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="drgIncome"
                            align="right"
                            sortable="custom"
                            label="DRG盈亏"
                            min-width="85">
                            <template slot-scope="scope">
                                {{scope.row.drgIncome | getMoneyNum}}
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="hospitalDays"
                            align="center"
                            sortable="custom"
                            label="住院日"
                            min-width="65">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            align="center"
                            label="组均住院日">
                            <el-table-column
                                show-overflow-tooltip
                                prop="drgAvgDays"
                                align="center"
                                label="院内"
                                min-width="50">
                                <template slot="header" slot-scope="scope">
                                    <el-tooltip class="item" effect="light" content="计算院内该组数据3年内的平均值" placement="top">
                                        <span>院内</span>
                                    </el-tooltip>
                                </template>
                                <template slot-scope="scope">
                                    <span v-if="scope.row.state === '已入组'">{{scope.row.drgAvgDays}}</span>
                                    <span v-else>{{scope.row.drgAvgDays ? scope.row.drgAvgDays : '/'}}</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="drgStandardDays"
                                align="center"
                                sortable="custom"
                                label="区域"
                                min-width="55">
                                <template slot-scope="scope">
                                    <span v-if="scope.row.state === '已入组'">{{scope.row.drgStandardDays}}</span>
                                    <span v-else>{{scope.row.drgStandardDays ? scope.row.drgStandardDays : '/'}}</span>
                                </template>
                            </el-table-column>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="drgCode"
                            align="center"
                            sortable="custom"
                            label="分组编码"
                            min-width="70">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="drgName"
                            align="left"
                            label="分组名称"
                            min-width="100">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="type"
                            align="center"
                            sortable="custom"
                            label="类型"
                            min-width="65">
                            <template slot-scope="scope">
                                <span :class="{'status-blue': scope.row.type === 1, 'status-red': scope.row.type === 2}">{{scope.row.type | getType}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="riskLevel"
                            align="center"
                            sortable="custom"
                            label="风险等级"
                            min-width="80">
                            <template slot-scope="scope">
                                {{scope.row.riskLevel | getRiskLevel}}
                            </template>
                        </el-table-column>
                        <!--<el-table-column-->
                            <!--show-overflow-tooltip-->
                            <!--label="操作"-->
                            <!--align="center"-->
                            <!--fixed="right"-->
                            <!--width="50">-->
                            <!--<template slot-scope="scope">-->
                                <!--<el-button type="text" :disabled="!viewInfoMonth(scope.row.dischargeDate)"-->
                                           <!--@click="toInfo(scope.$index)">明细-->
                                <!--</el-button>-->
                            <!--</template>-->
                        <!--</el-table-column>-->
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="未入组" name="not">
                    <el-table
                        border
                        v-if="activeName === 'not'"
                        :data="tableData"
                        row-key="id"
                        :max-height="tableHeight"
                        tooltip-effect="light"
                        style="width: 100%"
                        :empty-text="emptyText"
                        @sort-change="sortChange"
                        @selection-change="handleSelectionChange">
                        <el-table-column
                            show-overflow-tooltip
                            type="selection"
                            align="center"
                            width="30">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="date"
                            align="center"
                            type="index"
                            label="序号"
                            width="40">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="medicalRecordSign"
                            align="center"
                            label="病案号"
                            min-width="90">
                            <template slot-scope="scope">
                                <el-button type="text" :disabled="!viewInfoMonth(scope.row.dischargeDate)"
                                           @click="toInfo(scope.$index)">{{scope.row.medicalRecordSign}}
                                </el-button>
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="patientName"
                            align="left"
                            label="患者姓名"
                            min-width="65">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="dischargeDate"
                            align="center"
                            sortable="custom"
                            label="出院时间"
                            min-width="85">
                            <template slot-scope="scope">
                                {{scope.row.dischargeDate.substring(0, 10)}}
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="hospitalTime"
                            align="center"
                            sortable="custom"
                            label="住院次数"
                            min-width="80">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="diagnosis"
                            align="left"
                            label="主要诊断"
                            min-width="200">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="surgery"
                            align="left"
                            label="主要手术及操作"
                            min-width="200">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="totalFee"
                            align="center"
                            sortable="custom"
                            label="住院总费用"
                            min-width="95">
                            <template slot-scope="scope">
                                {{scope.row.totalFee | getMoneyNum}}
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="hospitalDays"
                            align="center"
                            sortable="custom"
                            label="住院日"
                            min-width="65">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="reason"
                            align="left"
                            label="未入组提示"
                            min-width="100">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="state"
                            align="center"
                            sortable="custom"
                            label="状态"
                            min-width="60"
                            fixed="right">
                            <template slot-scope="scope">
                                <span class="status-red">{{scope.row.state}}</span>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="排除组" name="exclude">
                    <el-table
                        border
                        v-if="activeName === 'exclude'"
                        :data="tableData"
                        row-key="id"
                        :max-height="tableHeight"
                        tooltip-effect="light"
                        style="width: 100%"
                        :empty-text="emptyText"
                        @sort-change="sortChange"
                        @selection-change="handleSelectionChange">
                        <el-table-column
                            show-overflow-tooltip
                            type="selection"
                            align="center"
                            width="50">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="date"
                            align="center"
                            type="index"
                            label="序号"
                            width="50">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="medicalRecordSign"
                            align="center"
                            label="病案号"
                            min-width="140">
                            <template slot-scope="scope">
                                <el-button type="text" :disabled="!viewInfoMonth(scope.row.dischargeDate)"
                                           @click="toInfo(scope.$index)">{{scope.row.medicalRecordSign}}
                                </el-button>
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            fixed
                            prop="patientName"
                            align="left"
                            label="患者姓名"
                            min-width="140">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="dischargeDate"
                            align="center"
                            sortable="custom"
                            label="出院时间"
                            min-width="110">
                            <template slot-scope="scope">
                                {{scope.row.dischargeDate.substring(0, 10)}}
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="hospitalTime"
                            align="center"
                            sortable="custom"
                            label="住院次数"
                            min-width="140">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="totalFee"
                            align="center"
                            sortable="custom"
                            label="住院总费用"
                            min-width="140">
                            <template slot-scope="scope">
                                {{scope.row.totalFee | getMoneyNum}}
                            </template>
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="hospitalDays"
                            align="center"
                            sortable="custom"
                            label="住院日"
                            min-width="140">
                        </el-table-column>
                        <el-table-column
                            show-overflow-tooltip
                            prop="reason"
                            align="left"
                            label="排除条件"
                            min-width="200">
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
            </el-tabs>
            <pagination v-show="tableData.length > 0" :total="total" :page.sync="currentPage" :limit.sync="pageSize"
                        @pagination="changePage"/>
        </div>
    </div>
</template>

<script>
    import {
        getOverviewAllList,
        getOverviewGroupList,
        getOverviewUngroupList,
        getOverviewExcludedList,
        exportOverviewList,
        exportGroupList,
        exportUngroupList,
        exportExcludedList
    } from '@/api/overview/list'
    import {getSortString, viewInfoMonth, getMoneyNum} from '@/utils/filters'
    import FileSaver from 'file-saver'
    import ExcelJS from 'exceljs'

    export default {
        name: 'index',
        data () {
            return {
                // 搜索条件
                form: {
                    hosDays: '',
                    keyword: ''
                },
                // 当前标签页
                activeName: 'all',
                // 当前页
                currentPage: 1,
                // 每页数量
                pageSize: 20,
                // 表格高度
                tableHeight: 0,
                // 表格数据
                tableData: [],
                // 数据总数
                total: 0,
                // 全局搜索内容，用于翻页等不传参时使用数据
                globalForm: {},
                // 排序字段
                sortMap: {},
                // 排序方式
                sortType: '',
                // 选中的数据
                multipleSelection: [],
                // 空数据时显示的文本内容
                emptyText: '暂无数据',
                // 使用储存的数据，不去请求
                useStore: false,
                // 导出的全部数据
                allexportData: []
            }
        },
        created () {
            // tags判断入口是否从选项卡进入
            this.useStore = this.$route.query.tags === 'tags'
            this.initPage()
            // 头部40 + 快捷标签30 + 面包屑30 + 搜索框42 + tabs高度34 + 分页64 + 底部padding10
            let height = document.documentElement.clientHeight - 100 - 42 - 34 - 64 - 10
            this.tableHeight = height > 108 ? height : 108
        },
        mounted () {
            let searchHeight = document.getElementsByClassName('global-tool-search')[0].offsetHeight
            if (searchHeight > 42) {
                let height = document.documentElement.clientHeight - 100 - searchHeight - 34 - 64 - 10
                this.tableHeight = height > 108 ? height : 108
            }
            // 白色背景高度
            document.getElementsByClassName('tables-box')[0].style.height = this.tableHeight + 34 + 64 + 'px'
            // 分页组件位置，不能使用bottom = 0，当位置发生变化时会出错
            document.getElementsByClassName('pagination-container')[0].style.top = this.tableHeight + 34 + 'px'
            window.onresize = () => {
                let height = document.documentElement.clientHeight - 100 - searchHeight - 34 - 64 - 10
                this.tableHeight = height > 108 ? height : 108
                document.getElementsByClassName('tables-box')[0].style.height = this.tableHeight + 34 + 64 + 'px'
                document.getElementsByClassName('pagination-container')[0].style.top = this.tableHeight + 34 + 'px'
            }
        },
        methods: {
            viewInfoMonth,
            /**
             * 初始化页面参数
             */
            initPage () {
                let query = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                if (query.tab) {
                    this.activeName = query.tab
                } else {
                    this.activeName = 'all'
                    this.setGetStore(this.$route.name, {tab: this.activeName})
                }
                if (query) {
                    this.form.keyword = query.keyword
                    this.form.hosDays = query.hosDays
                    this.currentPage = query.pageIndex || 1
                    this.pageSize = query.pageSize || 20
                }
            },
            /**
             * 翻页
             */
            changePage () {
                this.submitSearch()
            },
            /**
             * 提交查询
             * @param form 筛选条件
             */
            submitSearch (form) {
                let data = form || this.globalForm
                this.globalForm = data
                let params = {
                    ...data,
                    patientState: 0,
                    hosDays: this.form.hosDays,
                    pageSize: this.pageSize,
                    pageIndex: this.currentPage,
                    keyword: this.form.keyword,
                    orderBy: this.sortType
                }
                this.tableData = []
                this.setGetStore(this.$route.name, params)
                switch (this.activeName) {
                case 'all':
                    this.getAllList(params)
                    break
                case 'included':
                    this.getIncludedList(params)
                    break
                case 'not':
                    this.getNotList(params)
                    break
                case 'exclude':
                    this.getExcludeList(params)
                    break
                }
            },
            /**
             * 查询全部列表
             * @param params 请求参数
             */
            getAllList (params) {
                this.emptyText = '加载中...'
                if (this.getSession(this.$route.name, 'getOverviewAllList') && this.useStore) {
                    this.useStore = false
                    let res = this.getSession(this.$route.name, 'getOverviewAllList')
                    this.emptyText = '暂无数据'
                    if (res.code.toString() === '200') {
                        this.total = res.data.total
                        this.tableData = res.data.rows
                        this.sortMap = res.data.maps
                    }
                } else {
                    getOverviewAllList(params).then(res => {
                        this.useStore = false
                        this.setSession(this.$route.name, {getOverviewAllList: res})
                        this.emptyText = '暂无数据'
                        if (res.code.toString() === '200') {
                            this.total = res.data.total
                            this.tableData = res.data.rows
                            this.sortMap = res.data.maps
                        }
                    }).catch(() => {
                        this.emptyText = '暂无数据'
                    })
                }
            },
            /**
             * 查询已入组列表
             * @param params 请求参数
             */
            getIncludedList (params) {
                this.emptyText = '加载中...'
                if (this.getSession(this.$route.name, 'getOverviewGroupList') && this.useStore) {
                    this.useStore = false
                    let res = this.getSession(this.$route.name, 'getOverviewGroupList')
                    this.emptyText = '暂无数据'
                    if (res.code.toString() === '200') {
                        this.total = res.data.total
                        this.tableData = res.data.rows
                        this.sortMap = res.data.maps
                    }
                } else {
                    getOverviewGroupList(params).then(res => {
                        this.useStore = false
                        this.setSession(this.$route.name, {getOverviewGroupList: res})
                        this.emptyText = '暂无数据'
                        if (res.code.toString() === '200') {
                            this.total = res.data.total
                            this.tableData = res.data.rows
                            this.sortMap = res.data.maps
                        }
                    }).catch(() => {
                        this.emptyText = '暂无数据'
                    })
                }
            },
            /**
             * 查询未入组列表
             * @param params 请求参数
             */
            getNotList (params) {
                this.emptyText = '加载中...'
                if (this.getSession(this.$route.name, 'getOverviewUngroupList') && this.useStore) {
                    this.useStore = false
                    let res = this.getSession(this.$route.name, 'getOverviewUngroupList')
                    this.emptyText = '暂无数据'
                    if (res.code.toString() === '200') {
                        this.total = res.data.total
                        this.tableData = res.data.rows
                        this.sortMap = res.data.maps
                    }
                } else {
                    getOverviewUngroupList(params).then(res => {
                        this.useStore = false
                        this.setSession(this.$route.name, {getOverviewUngroupList: res})
                        this.emptyText = '暂无数据'
                        if (res.code.toString() === '200') {
                            this.total = res.data.total
                            this.tableData = res.data.rows
                            this.sortMap = res.data.maps
                        }
                    }).catch(() => {
                        this.emptyText = '暂无数据'
                    })
                }
            },
            /**
             * 查询排除组列表
             * @param params 请求参数
             */
            getExcludeList (params) {
                this.emptyText = '加载中...'
                if (this.getSession(this.$route.name, 'getOverviewExcludedList') && this.useStore) {
                    this.useStore = false
                    let res = this.getSession(this.$route.name, 'getOverviewExcludedList')
                    this.emptyText = '暂无数据'
                    if (res.code.toString() === '200') {
                        this.total = res.data.total
                        this.tableData = res.data.rows
                        this.sortMap = res.data.maps
                    }
                } else {
                    getOverviewExcludedList(params).then(res => {
                        this.useStore = false
                        this.setSession(this.$route.name, {getOverviewExcludedList: res})
                        this.emptyText = '暂无数据'
                        if (res.code.toString() === '200') {
                            this.total = res.data.total
                            this.tableData = res.data.rows
                            this.sortMap = res.data.maps
                        }
                    }).catch(() => {
                        this.emptyText = '暂无数据'
                    })
                }
            },
            /**
             * 切换标签页
             */
            handleClick () {
                this.tableData = []
                this.currentPage = 1
                this.sortType = ''
                this.setGetStore(this.$route.name, {tab: this.activeName})
                this.submitSearch()
                this.multipleSelection = []
            },
            /**
             * 前往病案详情
             * @param index 索引
             */
            toInfo (index) {
                // 获取当前页面筛选条件
                let query = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                // 获取数据索引（详情页每页是1条，即是详情页页码）
                let pageIndex = (this.currentPage - 1) * this.pageSize + index + 1
                this.$store.dispatch('search/coverSearchFormItem', {
                    pageName: 'OverviewListInfo',
                    query: {...query, pageIndex}
                })
                this.$router.push({name: 'OverviewListInfo'})
            },
            /**
             * 选中事件
             */
            handleSelectionChange (val) {
                this.multipleSelection = val
            },
            /**
             * 获取选中id
             */
            getSelectId () {
                let arr = []
                if (this.multipleSelection.length) {
                    this.multipleSelection.forEach(item => {
                        arr.push(item.medicalRecordID)
                    })
                    return arr
                } else {
                    return false
                }
            },
            /**
             * 导出文件
             */
            toExport () {
                switch (this.activeName) {
                case 'all':
                    this.toExportAll()
                    break
                case 'included':
                    this.toExportIncluded()
                    break
                case 'not':
                    this.toExportNot()
                    break
                case 'exclude':
                    this.toExportExclude()
                    break
                }
            },
            /**
             * 导出数据列表全部
             */
            toExportAll () {
                let params = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                params.idList = this.getSelectId() || []
                this.$store.dispatch('app/UpdateLoadingText', '0%')
                this.$store.dispatch('app/UpdateIsExport', true)
                this.$store.dispatch('app/UpdateLoading', true)
                params.pageIndex = 1
                params.pageSize = 1000
                this.allexportData = []
                this.sendRequest(params)
            },
            /**
             * 发送请求
             * @param params 请求参数
             */
            sendRequest (params) {
                let allIndex = Math.ceil(this.total / 1000)
                exportOverviewList(params).then(res => {
                    if (res.code.toString() === '200') {
                        this.$store.dispatch('app/UpdateLoadingText', parseInt(params.pageIndex / allIndex * 95) + '%')
                        this.allexportData = this.allexportData.concat(res.data)
                        if (params.pageIndex < allIndex) {
                            this.sendRequest({...params, pageIndex: params.pageIndex + 1})
                        } else {
                            this.exportDataList('病案数据列表', this.allexportData)
                        }
                    } else {
                        this.$store.dispatch('app/UpdateIsExport', false)
                        this.$store.dispatch('app/UpdateLoading', false)
                        this.$message.error('导出失败')
                    }
                }).catch(() => {
                    this.$store.dispatch('app/UpdateIsExport', false)
                    this.$store.dispatch('app/UpdateLoading', false)
                    this.$message.error('导出失败')
                })
            },
            /**
             * 导出excel表头
             */
            getHeader () {
                return [{
                    key: 'index', width: 10
                }, {
                    key: 'medicalRecordSign', width: 16
                }, {
                    key: 'patientName', width: 12
                }, {
                    key: 'dischargeDate', width: 16
                }, {
                    key: 'hospitalTime', width: 12
                }, {
                    key: 'totalFee', width: 16
                }, {
                    key: 'drgAvgFee', width: 16
                }, {
                    key: 'drgStandardFee', width: 16
                }, {
                    key: 'drgIncome', width: 24
                }, {
                    key: 'hospitalDays', width: 12
                }, {
                    key: 'drgAvgDays', width: 12
                }, {
                    key: 'drgStandardDays', width: 12
                }, {
                    key: 'drgCode', width: 16
                }, {
                    key: 'drgName', width: 32
                }, {
                    key: 'type', width: 16
                }, {
                    key: 'riskLevel', width: 16
                }, {
                    key: 'state', width: 16
                }]
            },
            /**
             * 导出列表excel
             */
            exportDataList (name, data) {
                let workbook = new ExcelJS.Workbook()
                workbook.creator = 'lyliang'
                workbook.views = [{
                    x: 0,
                    y: 0,
                    firstSheet: 0,
                    activeTab: 1,
                    visibility: 'visible'
                }]
                let worksheet = workbook.addWorksheet('Sheet1')
                /* eslint-disable */
                worksheet.getRow(1).values = ['序号', '病案号', '患者姓名', '出院时间', '住院次数', '住院总费用', '组均住院费用', , 'DRG盈亏', '住院日', '组均住院日', , '分组编码', '分组名称', '类型', '风险等级', '状态']
                /* eslint-enable */
                worksheet.getRow(2).values = ['序号', '病案号', '患者姓名', '出院时间', '住院次数', '住院总费用', '院内', '区域', 'DRG盈亏', '住院日', '院内', '区域', '分组编码', '分组名称', '类型', '风险等级', '状态']
                worksheet.columns = this.getHeader()
                worksheet.mergeCells('A1:A2')
                worksheet.mergeCells('B1:B2')
                worksheet.mergeCells('C1:C2')
                worksheet.mergeCells('D1:D2')
                worksheet.mergeCells('E1:E2')
                worksheet.mergeCells('F1:F2')
                worksheet.mergeCells('I1:I2')
                worksheet.mergeCells('J1:J2')
                worksheet.mergeCells('M1:M2')
                worksheet.mergeCells('N1:N2')
                worksheet.mergeCells('O1:O2')
                worksheet.mergeCells('P1:P2')
                worksheet.mergeCells('Q1:Q2')
                worksheet.mergeCells('G1:H1')
                worksheet.mergeCells('K1:L1')
                for (let i = 0; i < data.length; i++) {
                    data[i].index = i + 1
                    data[i].dischargeDate = data[i].dischargeDate.substring(0, 10)
                    data[i].totalFee = getMoneyNum(data[i].totalFee)
                    data[i].drgAvgFee = data[i].state === '已入组' || data[i].drgAvgFee ? getMoneyNum(data[i].drgAvgFee) : '/'
                    data[i].drgStandardFee = data[i].state === '已入组' || data[i].drgStandardFee ? getMoneyNum(data[i].drgStandardFee) : '/'
                    data[i].drgIncome = data[i].state === '已入组' || data[i].drgIncome ? getMoneyNum(data[i].drgIncome) : '/'
                    data[i].drgAvgDays = data[i].state === '已入组' || data[i].drgAvgDays ? data[i].drgAvgDays : '/'
                    data[i].drgStandardDays = data[i].state === '已入组' || data[i].drgStandardDays ? data[i].drgStandardDays : '/'
                    if (data[i].multiGroup.length) {
                        let str = ''
                        let strName = ''
                        data[i].multiGroup.forEach((item, index) => {
                            str += `${index + 1}、${item.key}`
                            strName += `${index + 1}、${item.value}`
                            if (index !== data[i].multiGroup.length - 1) {
                                str += '\r\n'
                                strName += '\r\n'
                            }
                        })
                        data[i].drgCode = str
                        data[i].drgName = strName
                    }
                    data[i].type = data[i].state === '已入组' ? this.$options.filters['getType'](data[i].type) : '/'
                    data[i].riskLevel = data[i].state === '已入组' ? this.$options.filters['getRiskLevel'](data[i].riskLevel) : '/'
                    worksheet.addRow(data[i])
                    worksheet.getRow(i + 1).alignment = {vertical: 'middle', horizontal: 'center'}
                    let rate = parseInt((i + 1) / data.length * 0.03 * 100 + 95) + '%'
                    this.$store.dispatch('app/UpdateLoadingText', rate)
                }
                worksheet.getRow(data.length + 1).alignment = {vertical: 'middle', horizontal: 'center'}
                worksheet.getRow(data.length + 2).alignment = {vertical: 'middle', horizontal: 'center'}
                worksheet.getColumn('drgName').alignment = {wrapText: true, vertical: 'middle', horizontal: 'left'}
                worksheet.getColumn('drgCode').alignment = {wrapText: true, vertical: 'middle', horizontal: 'center'}
                workbook.xlsx.writeBuffer().then(data => {
                    this.$store.dispatch('app/UpdateLoadingText', '99%')
                    let blob = new Blob([data], {type: 'EXCEL_TYPE'})
                    FileSaver.saveAs(blob, `${this.parseTime(new Date().getTime())} ${name}.xlsx`)
                    this.$store.dispatch('app/UpdateLoadingText', '100%')
                    this.$store.dispatch('app/UpdateIsExport', false)
                    this.$store.dispatch('app/UpdateLoading', false)
                })
            },
            /**
             * 导出数据列表已入组
             */
            toExportIncluded () {
                let params = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                params.idList = this.getSelectId() || []
                this.$store.dispatch('app/UpdateLoadingText', '0%')
                this.$store.dispatch('app/UpdateIsExport', true)
                this.$store.dispatch('app/UpdateLoading', true)
                params.pageIndex = 1
                params.pageSize = 1000
                this.allexportData = []
                this.sendRequestIncluded(params)
            },
            /**
             * 发送请求
             * @param params 请求参数
             */
            sendRequestIncluded (params) {
                let allIndex = Math.ceil(this.total / 1000)
                exportGroupList(params).then(res => {
                    if (res.code.toString() === '200') {
                        this.$store.dispatch('app/UpdateLoadingText', parseInt(params.pageIndex / allIndex * 95) + '%')
                        this.allexportData = this.allexportData.concat(res.data)
                        if (params.pageIndex < allIndex) {
                            this.sendRequestIncluded({...params, pageIndex: params.pageIndex + 1})
                        } else {
                            this.exportDataListIncluded('病案数据列表(已入组)', this.allexportData)
                        }
                    } else {
                        this.$store.dispatch('app/UpdateIsExport', false)
                        this.$store.dispatch('app/UpdateLoading', false)
                        this.$message.error('导出失败')
                    }
                }).catch(() => {
                    this.$store.dispatch('app/UpdateIsExport', false)
                    this.$store.dispatch('app/UpdateLoading', false)
                    this.$message.error('导出失败')
                })
            },
            /**
             * 导出excel表头
             */
            getHeaderIncluded () {
                return [{
                    key: 'index', width: 10
                }, {
                    key: 'medicalRecordSign', width: 16
                }, {
                    key: 'patientName', width: 12
                }, {
                    key: 'dischargeDate', width: 16
                }, {
                    key: 'hospitalTime', width: 12
                }, {
                    key: 'totalFee', width: 16
                }, {
                    key: 'drgAvgFee', width: 16
                }, {
                    key: 'drgStandardFee', width: 24
                }, {
                    key: 'drgIncome', width: 24
                }, {
                    key: 'hospitalDays', width: 12
                }, {
                    key: 'drgAvgDays', width: 12
                }, {
                    key: 'drgStandardDays', width: 12
                }, {
                    key: 'drgCode', width: 16
                }, {
                    key: 'drgName', width: 32
                }, {
                    key: 'type', width: 16
                }, {
                    key: 'riskLevel', width: 16
                }]
            },
            /**
             * 导出列表excel
             */
            exportDataListIncluded (name, data) {
                let workbook = new ExcelJS.Workbook()
                workbook.creator = 'lyliang'
                workbook.views = [{
                    x: 0,
                    y: 0,
                    firstSheet: 0,
                    activeTab: 1,
                    visibility: 'visible'
                }]
                let worksheet = workbook.addWorksheet('Sheet1')
                /* eslint-disable */
                worksheet.getRow(1).values = ['序号', '病案号', '患者姓名', '出院时间', '住院次数', '住院总费用', '组均住院费用', , 'DRG盈亏', '住院日', '组均住院日', , '分组编码', '分组名称', '类型', '风险等级']
                /* eslint-enable */
                worksheet.getRow(2).values = ['序号', '病案号', '患者姓名', '出院时间', '住院次数', '住院总费用', '院内', '区域', 'DRG盈亏', '住院日', '院内', '区域', '分组编码', '分组名称', '类型', '风险等级']
                worksheet.columns = this.getHeaderIncluded()
                worksheet.mergeCells('A1:A2')
                worksheet.mergeCells('B1:B2')
                worksheet.mergeCells('C1:C2')
                worksheet.mergeCells('D1:D2')
                worksheet.mergeCells('E1:E2')
                worksheet.mergeCells('F1:F2')
                worksheet.mergeCells('I1:I2')
                worksheet.mergeCells('J1:J2')
                worksheet.mergeCells('M1:M2')
                worksheet.mergeCells('N1:N2')
                worksheet.mergeCells('O1:O2')
                worksheet.mergeCells('P1:P2')
                worksheet.mergeCells('G1:H1')
                worksheet.mergeCells('K1:L1')
                for (let i = 0; i < data.length; i++) {
                    data[i].index = i + 1
                    data[i].dischargeDate = data[i].dischargeDate.substring(0, 10)
                    data[i].totalFee = getMoneyNum(data[i].totalFee)
                    data[i].drgAvgFee = data[i].state === '已入组' || data[i].drgAvgFee ? getMoneyNum(data[i].drgAvgFee) : '/'
                    data[i].drgStandardFee = data[i].state === '已入组' || data[i].drgStandardFee ? getMoneyNum(data[i].drgStandardFee) : '/'
                    data[i].drgIncome = getMoneyNum(data[i].drgIncome)
                    data[i].drgAvgDays = data[i].state === '已入组' || data[i].drgAvgDays ? data[i].drgAvgDays : '/'
                    data[i].drgStandardDays = data[i].state === '已入组' || data[i].drgStandardDays ? data[i].drgStandardDays : '/'
                    data[i].type = this.$options.filters['getType'](data[i].type)
                    data[i].riskLevel = this.$options.filters['getRiskLevel'](data[i].riskLevel)
                    worksheet.addRow(data[i])
                    worksheet.getRow(i + 1).alignment = {vertical: 'middle', horizontal: 'center'}
                    let rate = parseInt((i + 1) / data.length * 0.03 * 100 + 95) + '%'
                    this.$store.dispatch('app/UpdateLoadingText', rate)
                }
                worksheet.getRow(data.length + 1).alignment = {vertical: 'middle', horizontal: 'center'}
                worksheet.getRow(data.length + 2).alignment = {vertical: 'middle', horizontal: 'center'}
                worksheet.getColumn('drgName').alignment = {wrapText: true, vertical: 'middle', horizontal: 'left'}
                worksheet.getColumn('drgCode').alignment = {wrapText: true, vertical: 'middle', horizontal: 'center'}
                workbook.xlsx.writeBuffer().then(data => {
                    this.$store.dispatch('app/UpdateLoadingText', '99%')
                    let blob = new Blob([data], {type: 'EXCEL_TYPE'})
                    FileSaver.saveAs(blob, `${this.parseTime(new Date().getTime())} ${name}.xlsx`)
                    this.$store.dispatch('app/UpdateLoadingText', '100%')
                    this.$store.dispatch('app/UpdateIsExport', false)
                    this.$store.dispatch('app/UpdateLoading', false)
                })
            },
            /**
             * 导出数据列表未入组
             */
            toExportNot () {
                let params = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                params.idList = this.getSelectId() || []
                this.$store.dispatch('app/UpdateLoadingText', '0%')
                this.$store.dispatch('app/UpdateIsExport', true)
                this.$store.dispatch('app/UpdateLoading', true)
                params.pageIndex = 1
                params.pageSize = 1000
                this.allexportData = []
                this.sendRequestNot(params)
            },
            /**
             * 发送请求
             * @param params 请求参数
             */
            sendRequestNot (params) {
                let allIndex = Math.ceil(this.total / 1000)
                exportUngroupList(params).then(res => {
                    if (res.code.toString() === '200') {
                        this.$store.dispatch('app/UpdateLoadingText', parseInt(params.pageIndex / allIndex * 95) + '%')
                        this.allexportData = this.allexportData.concat(res.data)
                        if (params.pageIndex < allIndex) {
                            this.sendRequestNot({...params, pageIndex: params.pageIndex + 1})
                        } else {
                            this.exportDataListNot('病案数据列表(未入组)', this.allexportData)
                        }
                    } else {
                        this.$store.dispatch('app/UpdateIsExport', false)
                        this.$store.dispatch('app/UpdateLoading', false)
                        this.$message.error('导出失败')
                    }
                }).catch(() => {
                    this.$store.dispatch('app/UpdateIsExport', false)
                    this.$store.dispatch('app/UpdateLoading', false)
                    this.$message.error('导出失败')
                })
            },
            /**
             * 导出excel表头
             */
            getHeaderNot () {
                return [{
                    header: '序号', key: 'index', width: 10
                }, {
                    header: '病案号', key: 'medicalRecordSign', width: 16
                }, {
                    header: '患者姓名', key: 'patientName', width: 12
                }, {
                    header: '出院时间', key: 'dischargeDate', width: 16
                }, {
                    header: '住院次数', key: 'hospitalTime', width: 12
                }, {
                    header: '主要诊断', key: 'diagnosis', width: 32
                }, {
                    header: '主要手术及操作', key: 'surgery', width: 32
                }, {
                    header: '住院总费用', key: 'totalFee', width: 32
                }, {
                    header: '住院日', key: 'hospitalDays', width: 12
                }, {
                    header: '未入组提示', key: 'reason', width: 48
                }, {
                    header: '状态', key: 'state', width: 16
                }]
            },
            /**
             * 导出列表excel
             */
            exportDataListNot (name, data) {
                let workbook = new ExcelJS.Workbook()
                workbook.creator = 'lyliang'
                workbook.views = [{
                    x: 0,
                    y: 0,
                    firstSheet: 0,
                    activeTab: 1,
                    visibility: 'visible'
                }]
                let worksheet = workbook.addWorksheet('Sheet1')
                worksheet.columns = this.getHeaderNot()
                for (let i = 0; i < data.length; i++) {
                    data[i].index = i + 1
                    data[i].dischargeDate = data[i].dischargeDate.substring(0, 10)
                    data[i].totalFee = getMoneyNum(data[i].totalFee)
                    worksheet.addRow(data[i])
                    worksheet.getRow(i + 1).alignment = {vertical: 'middle', horizontal: 'center'}
                    let rate = parseInt((i + 1) / data.length * 0.03 * 100 + 95) + '%'
                    this.$store.dispatch('app/UpdateLoadingText', rate)
                }
                worksheet.getRow(data.length + 1).alignment = {vertical: 'middle', horizontal: 'center'}
                worksheet.getColumn('diagnosis').alignment = {wrapText: true, vertical: 'middle', horizontal: 'left'}
                worksheet.getColumn('surgery').alignment = {wrapText: true, vertical: 'middle', horizontal: 'left'}
                worksheet.getColumn('reason').alignment = {wrapText: true, vertical: 'middle', horizontal: 'left'}
                workbook.xlsx.writeBuffer().then(data => {
                    this.$store.dispatch('app/UpdateLoadingText', '99%')
                    let blob = new Blob([data], {type: 'EXCEL_TYPE'})
                    FileSaver.saveAs(blob, `${this.parseTime(new Date().getTime())} ${name}.xlsx`)
                    this.$store.dispatch('app/UpdateLoadingText', '100%')
                    this.$store.dispatch('app/UpdateIsExport', false)
                    this.$store.dispatch('app/UpdateLoading', false)
                })
            },
            /**
             * 导出数据列表排除组
             */
            toExportExclude () {
                let params = JSON.parse(JSON.stringify(this.$store.state.search.searchForm[this.$route.name]))
                params.idList = this.getSelectId() || []
                this.$store.dispatch('app/UpdateLoadingText', '0%')
                this.$store.dispatch('app/UpdateIsExport', true)
                this.$store.dispatch('app/UpdateLoading', true)
                params.pageIndex = 1
                params.pageSize = 1000
                this.allexportData = []
                this.sendRequestExclude(params)
            },
            /**
             * 发送请求
             * @param params 请求参数
             */
            sendRequestExclude (params) {
                let allIndex = Math.ceil(this.total / 1000)
                exportExcludedList(params).then(res => {
                    if (res.code.toString() === '200') {
                        this.$store.dispatch('app/UpdateLoadingText', parseInt(params.pageIndex / allIndex * 95) + '%')
                        this.allexportData = this.allexportData.concat(res.data)
                        if (params.pageIndex < allIndex) {
                            this.sendRequestExclude({...params, pageIndex: params.pageIndex + 1})
                        } else {
                            this.exportDataListExclude('病案数据列表(排除组)', this.allexportData)
                        }
                    } else {
                        this.$store.dispatch('app/UpdateIsExport', false)
                        this.$store.dispatch('app/UpdateLoading', false)
                        this.$message.error('导出失败')
                    }
                }).catch(() => {
                    this.$store.dispatch('app/UpdateIsExport', false)
                    this.$store.dispatch('app/UpdateLoading', false)
                    this.$message.error('导出失败')
                })
            },
            /**
             * 导出excel表头
             */
            getHeaderExclude () {
                return [{
                    header: '序号', key: 'index', width: 10
                }, {
                    header: '病案号', key: 'medicalRecordSign', width: 16
                }, {
                    header: '患者姓名', key: 'patientName', width: 12
                }, {
                    header: '出院时间', key: 'dischargeDate', width: 16
                }, {
                    header: '住院次数', key: 'hospitalTime', width: 12
                }, {
                    header: '住院总费用', key: 'totalFee', width: 32
                }, {
                    header: '住院日', key: 'hospitalDays', width: 12
                }, {
                    header: '排除条件', key: 'reason', width: 48
                }]
            },
            /**
             * 导出列表excel
             */
            exportDataListExclude (name, data) {
                let workbook = new ExcelJS.Workbook()
                workbook.creator = 'lyliang'
                workbook.views = [{
                    x: 0,
                    y: 0,
                    firstSheet: 0,
                    activeTab: 1,
                    visibility: 'visible'
                }]
                let worksheet = workbook.addWorksheet('Sheet1')
                worksheet.columns = this.getHeaderExclude()
                for (let i = 0; i < data.length; i++) {
                    data[i].index = i + 1
                    data[i].dischargeDate = data[i].dischargeDate.substring(0, 10)
                    data[i].totalFee = getMoneyNum(data[i].totalFee)
                    worksheet.addRow(data[i])
                    worksheet.getRow(i + 1).alignment = {vertical: 'middle', horizontal: 'center'}
                    let rate = parseInt((i + 1) / data.length * 0.03 * 100 + 95) + '%'
                    this.$store.dispatch('app/UpdateLoadingText', rate)
                }
                worksheet.getRow(data.length + 1).alignment = {vertical: 'middle', horizontal: 'center'}
                worksheet.getColumn('reason').alignment = {wrapText: true, vertical: 'middle', horizontal: 'left'}
                workbook.xlsx.writeBuffer().then(data => {
                    this.$store.dispatch('app/UpdateLoadingText', '99%')
                    let blob = new Blob([data], {type: 'EXCEL_TYPE'})
                    FileSaver.saveAs(blob, `${this.parseTime(new Date().getTime())} ${name}.xlsx`)
                    this.$store.dispatch('app/UpdateLoadingText', '100%')
                    this.$store.dispatch('app/UpdateIsExport', false)
                    this.$store.dispatch('app/UpdateLoading', false)
                })
            },
            /**
             * 排序修改
             * @param colData.prop 排序参数
             * @param colData.order 正序倒序 ascending 升序 descending 降序 null 不排序默认
             */
            sortChange (colData) {
                this.sortType = getSortString(colData, this.sortMap)
                this.tableData = []
                this.currentPage = 1
                this.submitSearch()
            }
        },
        filters: {
            getMoneyNum,
            getType (val) {
                switch (val) {
                case 0:
                    return '正常'
                case 1:
                    return '低倍率'
                case 2:
                    return '高倍率'
                }
            },
            getRiskLevel (val) {
                switch (val) {
                case 0:
                    return ''
                case 1:
                    return '低'
                case 2:
                    return '中低'
                case 3:
                    return '中高'
                case 4:
                    return '高'
                }
            }
        },
        beforeDestroy () {
            window.onresize = null
        }
    }
</script>

<style scoped lang="scss">
    .dashboard-list-container {
        .el-form-item--mini.el-form-item {
            margin-bottom: 10px;
        }
        .form-days {
            position: relative;
            .days {
                width: 100px;
                /deep/ input {
                    padding-right: 28px;
                }
            }
            .unit {
                position: absolute;
                right: 7px;
                top: 5px;
                font-size: 14px;
                color: #3A9BFF;
                line-height: 18px;
            }
        }
        .tables-box {
            background: #fff;
            padding: 0 10px;
            position: relative;
            .pagination-container {
                position: absolute;
                top: 0;
                right: 0;
            }
        }
    }
    /deep/.el-table th>.cell {
        padding-right: 4px;
        padding-left: 4px;
    }
    /deep/.el-table .cell {
        padding-right: 4px;
        padding-left: 4px;
    }
    /deep/.el-table .caret-wrapper {
        width: 14px;
        height: 22px;
        margin-top: -2px;
        .sort-caret {
            left: 2px;
            &.ascending {
                top: 0;
            }
            &.descending {
                bottom: 0;
            }
        }
    }
</style>
